package ar.com.psicosoft.model.psicosoft;

import java.io.Serializable;

import javax.persistence.*;

import java.util.List;

/**
 * The persistent class for the cliente database table.
 * 
 */
@Entity
@Table(name = "cliente", schema = "psicosoft")
@NamedQueries({
		@NamedQuery(name = "Cliente.buscarPorId", query = "SELECT c FROM Cliente c WHERE c.idPersona = :idPersona"),
		@NamedQuery(name = "Cliente.buscarPorRazonSocial", query = "SELECT c FROM Cliente c WHERE c.razonSocial = :razonSocial"),
		@NamedQuery(name = "Cliente.buscarClientes", query = "SELECT c FROM Cliente c ORDER BY c.razonSocial"),
		@NamedQuery(name = "Cliente.eliminarClientePorId", query = "DELETE FROM Cliente c WHERE c.idPersona = :idPersona") })
@PrimaryKeyJoinColumn(name = "\"idPersona\"")
public class Cliente extends Persona implements Serializable {
	private static final long serialVersionUID = 1L;

	@Column(length = 30)
	private String contacto;

	@Column(length = 10)
	private String cuenta;

	@Column(name = "\"detallesPago\"", length = 60)
	private String detallesPago;

	@Column(name = "\"formaPago\"", length = 20)
	private String formaPago;

	@Column(length = 50)
	private String observaciones;

	@Column(name = "\"porcenDescuento\"")
	private double porcenDescuento;

	@Column(name = "\"razonSocial\"", nullable = false, length = 50)
	private String razonSocial;

	@Column(nullable = false, length = 2147483647)
	private String tipo;

	// uni-directional one-to-one association to Persona
	@OneToOne(targetEntity = Persona.class, cascade = CascadeType.ALL)
	@JoinColumn(name = "\"idPersona\"", unique = true, nullable = false, insertable = false, updatable = false)
	private Persona persona;

	// bi-directional many-to-one association to Factura
	@OneToMany(mappedBy = "cliente")
	private List<Factura> facturas;

	public Cliente() {
	}

	public String getContacto() {
		return this.contacto;
	}

	public void setContacto(String contacto) {
		this.contacto = contacto;
	}

	public String getCuenta() {
		return this.cuenta;
	}

	public void setCuenta(String cuenta) {
		this.cuenta = cuenta;
	}

	public String getDetallesPago() {
		return this.detallesPago;
	}

	public void setDetallesPago(String detallesPago) {
		this.detallesPago = detallesPago;
	}

	public String getFormaPago() {
		return this.formaPago;
	}

	public void setFormaPago(String formaPago) {
		this.formaPago = formaPago;
	}

	public String getObservaciones() {
		return this.observaciones;
	}

	public void setObservaciones(String observaciones) {
		this.observaciones = observaciones;
	}

	public double getPorcenDescuento() {
		return this.porcenDescuento;
	}

	public void setPorcenDescuento(double porcenDescuento) {
		this.porcenDescuento = porcenDescuento;
	}

	public String getRazonSocial() {
		return this.razonSocial;
	}

	public void setRazonSocial(String razonSocial) {
		this.razonSocial = razonSocial;
	}

	public String getTipo() {
		return this.tipo;
	}

	public void setTipo(String tipo) {
		this.tipo = tipo;
	}

	public Persona getPersona() {
		return this.persona;
	}

	public void setPersona(Persona persona) {
		this.persona = persona;
	}

	public List<Factura> getFacturas() {
		return this.facturas;
	}

	public void setFacturas(List<Factura> facturas) {
		this.facturas = facturas;
	}

	public Factura addFactura(Factura factura) {
		getFacturas().add(factura);
		factura.setCliente(this);

		return factura;
	}

	public Factura removeFactura(Factura factura) {
		getFacturas().remove(factura);
		factura.setCliente(null);

		return factura;
	}

}